﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace HML.Demo
{
    public partial class MainForm : Form
    {
        public static int GlobalSplitWidth = 350;
        public static string GlobalAssistTabControlSelectedText = "属性面板";
        private List<ItemFormTemplateViewObject> views = new List<ItemFormTemplateViewObject>();
        private bool isSingleAccordionChanging = false;

        public MainForm()
        {
            InitializeComponent();
        }

        private void Form_Load(object sender, EventArgs e)
        {
            this.Size = new Size((int)(1200 * this.singleAccordion.ScaleDpi), (int)(750 * this.singleAccordion.ScaleDpi));
            this.splitContainer.SplitterDistance = (int)(this.splitContainer.SplitterDistance * this.singleAccordion.ScaleDpi);
            this.LoadMenu();
            this.LoadTabControl();
        }

        private void Form_Shown(object sender, EventArgs e)
        {
            this.singleAccordion.SelectedNode = (SingleAccordionContentNode)this.singleAccordion.Nodes[0];
        }

        private void LoadMenu()
        {
            SingleAccordionContentNode home_contentNode = new SingleAccordionContentNode() { Text = "首页", Image = global::HML.Demo.Properties.Resources.MainMenu_Home, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = false, formType = typeof(首页Form) } };
            this.singleAccordion.Nodes.Add(home_contentNode);

            SingleAccordionCategoryNode button_categoryNode = new SingleAccordionCategoryNode() { Text = "按钮类" };
            button_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_ButtonPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ButtonPlusForm) } });
            button_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "开关按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_ToggleButton, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ToggleButtonForm) } });
            button_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "命令组按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_CommandButton, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(CommandButtonForm) } });
            button_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "滑动开关", Image = global::HML.Demo.Properties.Resources.MainMenu_ToggleSwitch, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ToggleSwitchForm) } });
            button_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "不规则形状按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_AnomalyButton, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(AnomalyButtonForm) } });
            this.singleAccordion.Nodes.Add(button_categoryNode);

            SingleAccordionCategoryNode input_categoryNode = new SingleAccordionCategoryNode() { Text = "输入类" };
            input_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "复选框", Image = global::HML.Demo.Properties.Resources.MainMenu_CheckBoxPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(CheckBoxPlusForm) } });
            input_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "单选按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_RadioButtonPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(RadioButtonPlusForm) } });
            input_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "日期输入框", Image = global::HML.Demo.Properties.Resources.MainMenu_DateInput, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(DateInputForm) } });
            input_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "日期面板", Image = global::HML.Demo.Properties.Resources.MainMenu_DatePicker, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(DatePickerForm) } });
            input_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "下拉列表", Image = global::HML.Demo.Properties.Resources.MainMenu_DropDownListPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(DropDownListPlusForm) } });
            this.singleAccordion.Nodes.Add(input_categoryNode);

            SingleAccordionCategoryNode track_categoryNode = new SingleAccordionCategoryNode() { Text = "滑条类" };
            track_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "多点滑块", Image = global::HML.Demo.Properties.Resources.MainMenu_MultidropSlide, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(MultidropSlideForm) } });
            track_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "单点滑块", Image = global::HML.Demo.Properties.Resources.MainMenu_TrackBarPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TrackBarPlusForm) } });
            track_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "Int角度", Image = global::HML.Demo.Properties.Resources.MainMenu_IntAngle, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(IntAngleForm) } });
            track_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "数字调整文本", Image = global::HML.Demo.Properties.Resources.MainMenu_NumeralAdjustLabel, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(NumeralAdjustLabelForm) } });
            this.singleAccordion.Nodes.Add(track_categoryNode);

            SingleAccordionCategoryNode progress_categoryNode = new SingleAccordionCategoryNode() { Text = "百分比类" };
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "环形进度", Image = global::HML.Demo.Properties.Resources.MainMenu_AnnulusProgress, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(AnnulusProgressForm) } });
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "圆弧进度", Image = global::HML.Demo.Properties.Resources.MainMenu_ArcProgress, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ArcProgressForm) } });
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "条形进度", Image = global::HML.Demo.Properties.Resources.MainMenu_LineProgress, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(LineProgressForm) } });
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "分块进度", Image = global::HML.Demo.Properties.Resources.MainMenu_PieceProgress, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(PieceProgressForm) } });
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "水波纹进度", Image = global::HML.Demo.Properties.Resources.MainMenu_WaterRipples, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(WaterRipplesForm) } });
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "横向渐变进度", Image = global::HML.Demo.Properties.Resources.MainMenu_HGradualPercentage, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(HGradualPercentageForm) } });
            progress_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "纵向渐变进度", Image = global::HML.Demo.Properties.Resources.MainMenu_HGradualPercentage, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(VGradualPercentageForm) } });
            this.singleAccordion.Nodes.Add(progress_categoryNode);

            SingleAccordionCategoryNode container_categoryNode = new SingleAccordionCategoryNode() { Text = "容器类" };
            container_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "分组框", Image = global::HML.Demo.Properties.Resources.MainMenu_GroupPanelPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(GroupPanelPlusForm) } });
            container_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "圆角容器", Image = global::HML.Demo.Properties.Resources.MainMenu_RoundContainer, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(RoundContainerForm) } });
            this.singleAccordion.Nodes.Add(container_categoryNode);

            SingleAccordionCategoryNode navigation_categoryNode = new SingleAccordionCategoryNode() { Text = "导航类" };
            navigation_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项卡", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusForm) } });
            navigation_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "手风琴菜单", Image = global::HML.Demo.Properties.Resources.MainMenu_SingleAccordion, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(SingleAccordionForm) } });
            navigation_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "步骤流程", Image = global::HML.Demo.Properties.Resources.MainMenu_Procedure, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(StepProgressForm) } });
            navigation_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "页码导航条", Image = global::HML.Demo.Properties.Resources.MainMenu_PaginationBar, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(PaginationBarForm) } });
            navigation_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "面包屑导航", Image = global::HML.Demo.Properties.Resources.MainMenu_BreadcrumbBar, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(BreadcrumbBarForm) } });
            this.singleAccordion.Nodes.Add(navigation_categoryNode);

            SingleAccordionCategoryNode play_categoryNode = new SingleAccordionCategoryNode() { Text = "播放类" };
            play_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "图片幻灯片", Image = global::HML.Demo.Properties.Resources.MainMenu_ImageSlide, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ImageSlideForm) } });
            play_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "文本滚动", Image = global::HML.Demo.Properties.Resources.MainMenu_TextSlide, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TextSlideForm) } });
            play_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "动态图片", Image = global::HML.Demo.Properties.Resources.MainMenu_GifBox, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(GifBoxForm) } });
            this.singleAccordion.Nodes.Add(play_categoryNode);

            SingleAccordionCategoryNode chart_categoryNode = new SingleAccordionCategoryNode() { Text = "图表类" };
            chart_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "仪表", Image = global::HML.Demo.Properties.Resources.MainMenu_Meter, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(MeterForm) } });
            chart_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "圆弧仪表", Image = global::HML.Demo.Properties.Resources.MainMenu_Meter, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ArcMeterForm) } });
            chart_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "温度计", Image = global::HML.Demo.Properties.Resources.MainMenu_Thermometer, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ThermometerForm) } });
            this.singleAccordion.Nodes.Add(chart_categoryNode);

            SingleAccordionCategoryNode display_categoryNode = new SingleAccordionCategoryNode() { Text = "显示类" };
            display_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "尺子", Image = global::HML.Demo.Properties.Resources.MainMenu_HRuler, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(RulerForm) } });
            display_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "角度旋转文本", Image = global::HML.Demo.Properties.Resources.MainMeun_AngleLabel, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(AngleLabelForm), } });
            display_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "分隔线", Image = global::HML.Demo.Properties.Resources.MainMenu_HHalvingLine, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(HHalvingLineForm) } });
            display_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "头像标签", Image = global::HML.Demo.Properties.Resources.MainMenu_PersonPicture, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(PersonPictureForm) } });
            display_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "加载等待", Image = global::HML.Demo.Properties.Resources.MainMenu_LoadWait, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(LoadWaitForm) } });
            this.singleAccordion.Nodes.Add(display_categoryNode);

            SingleAccordionCategoryNode control_categoryNode = new SingleAccordionCategoryNode() { Text = "功能类" };
            control_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "图片剪切", Image = global::HML.Demo.Properties.Resources.MainMenu_ImageCropper, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ImageCropperForm) } });
            control_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "图案手势", Image = global::HML.Demo.Properties.Resources.MainMenu_PatternLock, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(PatternLockForm) } });
            this.singleAccordion.Nodes.Add(control_categoryNode);

            SingleAccordionCategoryNode component_categoryNode = new SingleAccordionCategoryNode() { Text = "组件" };
            component_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "Tip提示", Image = global::HML.Demo.Properties.Resources.MainMenu_ToolTipPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ToolTipPlusForm) } });
            component_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "精准定时器", Image = global::HML.Demo.Properties.Resources.MainMenu_TimerPrecision, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TimerPrecisionForm) } });
            component_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "蒙版弹层", Image = global::HML.Demo.Properties.Resources.MainMenu_Masking, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(MaskingForm) } });
            this.singleAccordion.Nodes.Add(component_categoryNode);

            SingleAccordionCategoryNode tcbControl_categoryNode = new SingleAccordionCategoryNode() { Text = "选项卡风格功能" };
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项风格1", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusStyle1EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项风格2", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusStyle2EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项风格3", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusStyle3EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项风格4", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusStyle4EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项风格5", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusStyle5EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项风格6", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlusStyle6EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "下拉列表", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlus下拉列表EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "全局按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlus全局按钮EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项拖放排序", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlus拖放排序EffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项Click按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlus选项ClickButtomEffectForm) } });
            tcbControl_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "选项Check按钮", Image = global::HML.Demo.Properties.Resources.MainMenu_TabControlPlus, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(TabControlPlus选项CheckButtomEffectForm) } });
            this.singleAccordion.Nodes.Add(tcbControl_categoryNode);

            SingleAccordionCategoryNode singleAccordion_categoryNode = new SingleAccordionCategoryNode() { Text = "手风琴风格扩展" };
            singleAccordion_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "手风琴风格1", Image = global::HML.Demo.Properties.Resources.MainMenu_SingleAccordion, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(SingleAccordionStyle1EffectForm) } });
            singleAccordion_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "手风琴风格2", Image = global::HML.Demo.Properties.Resources.MainMenu_SingleAccordion, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(SingleAccordionStyle2EffectForm) } });
            singleAccordion_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "手风琴风格3", Image = global::HML.Demo.Properties.Resources.MainMenu_SingleAccordion, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(SingleAccordionStyle3EffectForm) } });
            singleAccordion_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "手风琴风格4", Image = global::HML.Demo.Properties.Resources.MainMenu_SingleAccordion, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(SingleAccordionStyle4EffectForm) } });
            this.singleAccordion.Nodes.Add(singleAccordion_categoryNode);

            SingleAccordionCategoryNode controlEffect_categoryNode = new SingleAccordionCategoryNode() { Text = "控件整体效果预览" };
            controlEffect_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "按钮", Image = global::HML.Demo.Properties.Resources.MainMeun_控件效果, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ButtonEffectForm) } });
            controlEffect_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "尺子", Image = global::HML.Demo.Properties.Resources.MainMeun_控件效果, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(RulerEffectForm) } });
            controlEffect_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "幻灯片", Image = global::HML.Demo.Properties.Resources.MainMeun_控件效果, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ImageSlideEffectForm) } });
            controlEffect_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "日期", Image = global::HML.Demo.Properties.Resources.MainMeun_控件效果, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(DateEffectForm) } });
            controlEffect_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "占比", Image = global::HML.Demo.Properties.Resources.MainMeun_控件效果, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(ProgressEffectForm) } });
            this.singleAccordion.Nodes.Add(controlEffect_categoryNode);

            SingleAccordionCategoryNode websiteDemo_categoryNode = new SingleAccordionCategoryNode() { Text = "仿网页模板效果" };
            websiteDemo_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "MyTask模板", Image = global::HML.Demo.Properties.Resources.MainMeun_网站模板, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(MyTaskDemoForm) } });
            websiteDemo_categoryNode.Childrens.Add(new SingleAccordionContentNode() { Text = "SimplaAdmin模板", Image = global::HML.Demo.Properties.Resources.MainMeun_网站模板, Tag = new MenuSetting() { id = Guid.NewGuid(), allowColse = true, formType = typeof(SimplaAdminDemoForm) } });
            this.singleAccordion.Nodes.Add(websiteDemo_categoryNode);

            this.singleAccordion.ExpandCollapse(false);
        }

        private void LoadTabControl()
        {
            this.tabControl.Picker.TabItem.Height = 24;
            this.tabControl.Picker.TabItem.IconVisible = true;


            TabControlPlusGlobalButtton drop_globalButtton = new TabControlPlusGlobalButtton();
            drop_globalButtton.LRMargin = new LRMargin(4, 4);
            drop_globalButtton.ImageNormal = global::HML.Demo.Properties.Resources.TabControl_Drop;
            drop_globalButtton.ImageEnter = global::HML.Demo.Properties.Resources.TabControl_Drop;
            drop_globalButtton.Key = "drop";
            this.tabControl.TabBar.GlobalButttons.Add(drop_globalButtton);
            this.tabControl.TabBar.GlobalButttons["drop"].GlobalButttonClick += this.TabControl_drop_GlobalCustomButttonClick;


            TabControlPlusGlobalButtton skin_globalButtton = new TabControlPlusGlobalButtton();
            skin_globalButtton.LRMargin = new LRMargin(4, 4);
            skin_globalButtton.ImageNormal = global::HML.Demo.Properties.Resources.TabControl_Skin;
            skin_globalButtton.ImageEnter = global::HML.Demo.Properties.Resources.TabControl_Skin;
            skin_globalButtton.Key = "skin";
            skin_globalButtton.TipText = "主题";
            this.tabControl.TabBar.GlobalButttons.Add(skin_globalButtton);
            this.tabControl.TabBar.GlobalButttons["skin"].GlobalButttonClick += this.TabControl_skin_GlobalCustomButttonClick;

            this.singleAccordion.SelectedNodeChanged += this.SingleAccordion_SelectedNodeChanged;
            this.tabControl.SelectedIndexChanged += this.TabControl_SelectedIndexChanged;

        }

        private void TabControl_drop_GlobalCustomButttonClick(object sender, TabControlPlusGlobalButttonEventArgs e)
        {
            TabControlPlus tabControl = (TabControlPlus)sender;
            if (tabControl.TabCount > 0)
            {
                RectangleF rect = e.GlobalButtton.GetRectangle();
                tabControl.ShowPicker(rect);
            }
        }

        private SkinPicker skinPicker = null;
        private void TabControl_skin_GlobalCustomButttonClick(object sender, TabControlPlusGlobalButttonEventArgs e)
        {
            TabControlPlus tabControl = (TabControlPlus)sender;
            if (tabControl.TabCount > 0)
            {
                RectangleF rect = e.GlobalButtton.GetRectangle();
                if (this.skinPicker == null)
                {
                    this.skinPicker = new SkinPicker(this.tabControl);
                    this.skinPicker.SkinController = this.skinController1;
                    this.skinPicker.ItemClick += this.SkinPicker_ItemClick;
                }

                Dictionary<string, Color> arr = new Dictionary<string, Color>();
                this.skinPicker.ItemsSource.Clear();
                this.skinPicker.SelectedItem = null;
                string[] skinNameArr = SkinManager.GetRegisterSkinNames();
                Dictionary<string, Color> dic = new Dictionary<string, Color>() { { Skins.Dark.ToString(),Color.FromArgb(32, 32, 32) }, { Skins.BluePurple.ToString(), Color.FromArgb(68, 70, 85) },{ Skins.DarkSatinette.ToString(), Color.FromArgb(54, 88, 128) } };
                for (int i = 0; i < skinNameArr.Length; i++)
                {
                    this.skinPicker.ItemsSource.Add(skinNameArr[i], dic[skinNameArr[i]]);
                }
                this.skinPicker.SelectedItem = SkinManager.ApplySkinName;
                this.skinPicker.ShowPicker(this.tabControl.RectangleToScreen(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height)));
            }
        }

        private void SkinPicker_ItemClick(object sender, SkinPickerItemClickEventArgs e)
        {
            SkinManager.Apply(e.Key);
        }

        private void SingleAccordion_SelectedNodeChanged(object sender, EventArgs e)
        {
            this.isSingleAccordionChanging = true;
            SingleAccordionContentNode contentNode = this.singleAccordion.SelectedNode;
            MenuSetting data = (MenuSetting)contentNode.Tag;
            if (this.views.Where(a => a.ViewMenu != null && ((MenuSetting)a.ViewMenu.Tag).id == data.id).Count() == 0)
            {
                ConstructorInfo _constructor = data.formType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { }, null);
                ItemFormTemplate viewForm = (ItemFormTemplate)_constructor.Invoke(new object[] { });
                viewForm.Dock = DockStyle.Fill;
                viewForm.TopLevel = false;
                viewForm.FormBorderStyle = FormBorderStyle.None;
                viewForm.Visible = true;

                TabPagePlus viewPage = new TabPagePlus();
                viewPage.TabItem.CloseButton.Visible = data.allowColse ? TabControlPlusTabItemCloseButtonVisibles.True : TabControlPlusTabItemCloseButtonVisibles.False;
                viewPage.TabItem.Icon.Image = contentNode.Image;
                viewPage.TabItem.AutoWidth = TabControlPlusTabItemAutoWidthMode.True;
                viewPage.TabItem.AutoWidthMin = 60;
                viewPage.Text = contentNode.Text;
                viewPage.Tag = data;
                viewPage.Controls.Add(viewForm);
                viewPage.TabItemCloseButtonClosed += Page_TabItemCloseButtonClosed;

                ItemFormTemplateViewObject view = new ItemFormTemplateViewObject() { ViewMenu = contentNode, ViewPage = viewPage, ViewForm = viewForm };
                this.views.Add(view);

                this.tabControl.TabPages.Add(viewPage);
                this.tabControl.SelectedTab = viewPage;
                Masking.Show(viewForm.FindForm());

                AsyncCallback asynchRequestTaskCallback = (result) =>
                {
                    ItemFormTemplateViewObject viewObject = ((Func<ItemFormTemplateViewObject, ItemFormTemplateViewObject>)result.AsyncState).EndInvoke(result);
                    viewObject.ViewForm.BeginInvoke(new Action<ItemFormTemplateViewObject>((_viewObject) =>
                    {
                        _viewObject.ViewForm.DataBind(_viewObject);
                        _viewObject.ViewForm.ViewStatus = ItemFormTemplateStatus.Bind;
                        _viewObject.ViewForm.ShowView();
                        if (_viewObject.ViewForm != null)
                        {
                            Masking.Hide(_viewObject.ViewForm);
                        }
                    }), viewObject);
                };

                Func<ItemFormTemplateViewObject, ItemFormTemplateViewObject> asynchRequestTaskHandle = ((IItemFormTemplate)viewForm).AsynchRequestTask;
                asynchRequestTaskHandle.BeginInvoke(view, asynchRequestTaskCallback, asynchRequestTaskHandle);

            }
            else
            {
                this.tabControl.SelectedTab = this.views.Where(a => a.ViewMenu != null && ((MenuSetting)a.ViewMenu.Tag).id == data.id).FirstOrDefault().ViewPage;
            }
            this.isSingleAccordionChanging = false;
        }

        private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < this.views.Count; i++)
            {
                if (this.views[i].ViewPage.Parent == this.tabControl && this.views[i].ViewPage == this.tabControl.SelectedTab && this.views[i].ViewForm.Parent == this.views[i].ViewPage)
                {
                    if (!this.views[i].ViewForm.ViewVisible)
                    {
                        this.views[i].ViewForm.ShowView();
                    }
                }
                else
                {
                    this.views[i].ViewForm.HideView();
                }
            }
            if (this.isSingleAccordionChanging == false)
            {
                SingleAccordionContentNode contentNode = null;
                for (int i = 0; i < this.views.Count; i++)
                {
                    if (this.views[i].ViewPage == this.tabControl.SelectedTab)
                    {
                        contentNode = this.views[i].ViewMenu;
                        break;
                    }
                }
                if (contentNode != null)
                {
                    this.singleAccordion.UpdateSelectedNode(contentNode);
                }
            }
        }

        private void Page_TabItemCloseButtonClosed(object sender, TabControlPlusTabItemCloseButtonClosedEventArgs e)
        {

            ItemFormTemplateViewObject viewObject = this.views.Where(a => a.ViewMenu != null && ((MenuSetting)a.ViewMenu.Tag).id == ((MenuSetting)e.TabPage.Tag).id).FirstOrDefault();
            if (viewObject.ViewForm != null)
            {
                viewObject.ViewForm.ViewStatus = ItemFormTemplateStatus.Closed;
                Masking.Hide(viewObject.ViewForm);
            }
            viewObject.ViewForm.HideView();
            viewObject.ViewForm.Dispose();
            this.views.Remove(viewObject);
            if (this.singleAccordion.SelectedNode == viewObject.ViewMenu)
            {
                this.singleAccordion.UpdateSelectedNode(null);
            }
        }

        internal static void LoadAssistTabControl(TabControlPlus assistTabControl)
        {
            if (MainForm.GlobalAssistTabControlSelectedText != "")
            {
                for (int i = 0; i < assistTabControl.TabPages.Count; i++)
                {
                    if (assistTabControl.TabPages[i].Text == MainForm.GlobalAssistTabControlSelectedText)
                    {
                        assistTabControl.SelectedTab = assistTabControl.TabPages[i];
                        break;
                    }
                }
            }
            assistTabControl.SelectedIndexChanged += MainForm.AssistTabControl_SelectedIndexChanged;
        }

        internal static void AssistTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabControlPlus control = (TabControlPlus)sender;
            MainForm.GlobalAssistTabControlSelectedText = control.SelectedTab == null ? "" : control.SelectedTab.Text;
        }

    }


    public class MenuSetting
    {
        public Guid id;
        public Type formType;
        public Image ico;
        public bool allowColse;
    }

}
